#ifndef _FUZZY_FCTH_PART_H
#define _FUZZY_FCTH_PART_H

#pragma once

#include <vector>
#include <iterator>

#ifndef MIN
#define MIN(a,b)  ((a) > (b) ? (b) : (a))
#endif

#ifndef MAX
#define MAX(a,b)  ((a) < (b) ? (b) : (a))
#endif

using namespace std;

class FuzzyFCTHpart
{
public:
	FuzzyFCTHpart(void);
	~FuzzyFCTHpart(void);

	vector<double> ApplyFilter(double F1, double F2, double F3, vector<double>& ColorValues, int Method,int NumberOfColors);

public:
	vector<double>	_ResultsTable;
	vector<double>	_HorizontalMembershipValues;
	vector<double>	_VerticalMembershipValues;
	vector<double>	_EnergyMembershipValues;

	struct FuzzyRules
	{
		int Input1;
		int Input2;
		int Input3;
		int Output;
	};

	vector<FuzzyRules>		_TextureRules;
	vector<double>			_FCTH;
	vector<double>			_HorizontalActivation;
	vector<double>			_VerticalActivation;
	vector<double>			_EnergyActivation;
	vector<vector<int> >	_RulesDefinition;

private:
	void ParamsInit();

	void FindMembershipValueForTriangles(double Input, vector<double>& Triangles, vector<double>& MembershipFunctionToSave);

	void LOM_Defazzificator(vector<FuzzyRules>& Rules, vector<double>& Input1, vector<double>& Input2, vector<double>& Input3, vector<double>& ResultTable);

	void MultiParticipate_Equal_Defazzificator(vector<FuzzyRules>& Rules, vector<double>& Input1, vector<double>& Input2, vector<double>& Input3, vector<double>& ResultTable);

	void MultiParticipate_Defazzificator(vector<FuzzyRules>& Rules, vector<double>& Input1, vector<double>& Input2, vector<double>& Input3, vector<double>& ResultTable);

};

#endif